import request from './request';


//封装请求-http.ts
const http = {
    get(url:string, params?:any) {
        const config = {
            method: 'get',
            url: url,
            params,
        }
        if (params) config.params = params;
        return request(config)
    },

    post(url: string, data?: any) {
        const config = {
            method: 'post',
            url: url,
            data,
        }
        if (data) config.data = data;
        return request(config)
    },

    put(url: string, data?: any) {
        const config = {
            method: 'put',
            url: url,
            data
        }
        if (data) config.data = data;
        return request(config)
    },

    delete(url: string, params?: any) {
        const config = {
            method: 'delete',
            url: url,
            params
        }
        if (params) config.params = params;
        return request(config)
    }

}

export default http
